<?php

namespace App\Http\Resources\user;


use App\Models\user\Address;
use Illuminate\Http\Resources\Json\ResourceCollection;

class AddressCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @return \Illuminate\Support\Collection
     */
    public function toArray($request)
    {
        return $this->collection->map(function (Address $item) {
            return [
                'id' => $item->id,
                'detail' => $item->detail,
                'name' => $item->name??'',
                'phone' => $item->phone,
                'is_default' => $item->is_default,
                'p_id' => $item->p_id,
                'c_id' => $item->c_id,
                'd_id' => $item->d_id,
                'p_name' => $item->p_name,
                'c_name' => $item->c_name,
                'd_name' => $item->d_name,
                'p_code' => $item->p_code,
                'c_code' => $item->c_code,
                'd_code' => $item->d_code,
            ];
        });
    }
}
